package com.xm.config;

import com.xm.interceptor.JwtTokenEmployeeInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置类，注册web层相关组件
 */
@Configuration
@Slf4j
public class WebMvcConfiguration  implements WebMvcConfigurer {



    @Autowired
    private JwtTokenEmployeeInterceptor jwtTokenEmployeeInterceptor;

    /**
     * 注册自定义拦截器
     *
     * @param registry
     */

    public void addInterceptors(InterceptorRegistry registry) {
        log.info("开始注册自定义拦截器...");
        //注册商家端的请求拦截器
        registry.addInterceptor(jwtTokenEmployeeInterceptor)
                .addPathPatterns("/takeout/**")
                .excludePathPatterns("/takeout/employee/login")
                .excludePathPatterns("/takeout/employee/register")
                .excludePathPatterns("/takeout/employee/eamliCode");
//        //注册用户端的请求拦截器
//        registry.addInterceptor(jwtTokenUserInterceptor)
//                .addPathPatterns("/user/**")
//                .excludePathPatterns("/user/user/login")
//                .excludePathPatterns("/user/shop/status");

    }




//    /**
//     * 设置静态资源映射
//     * @param registry
//     */
//    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
//        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
//    }



}
